package com.rs.controller.Rs;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rs.controller.Rs.DakaJFrame.SelectByDay;
import com.rs.controller.Rs.HRJFrame.SelectAll;
import com.rs.model.Adjustment;
import com.rs.model.Attendance;
import com.rs.model.Bonus;
import com.rs.model.Resign;
import com.rs.service.rs.DepartmentService;
import com.rs.util.DateFormatUtil;
import com.rs.util.SpringContextUtils;

public class HRJFrame extends JFrame {

	 private JPanel contentPane;
	
	 private JTextField username;//姓名
	 
	 private JComboBox<String> state;//状态

	 private JTextField daytime;//日期
	 
	 private JTable table;
	 
	 private Object [][]data=null;
		
	 private String head[]=null;
	 
	 private Adjustment aa;
	 
	 private Resign rr;
	
	 private Bonus bb;
	 
	    
	private static final long serialVersionUID = 1L;

	private DepartmentService dts = SpringContextUtils.getBean(DepartmentService.class);
	
	class SelectAll extends BumenJFrame {

		public SelectAll(List<Adjustment> ll, final int pages, final int yeshu,final int type,final Adjustment adj) {
			// TODO Auto-generated constructor stub
			super();
			//设置标题
			setTitle("职位调整申请记录");
			//设置大小
			setBounds(500,300,950,500);
			//主体
			contentPane = new JPanel();
			contentPane.setBorder(new EmptyBorder(500,300,950,500));
			setContentPane(contentPane);
			contentPane.setLayout(null);
			//创建1个字体实bai例
			Font font = new Font("宋体", Font.PLAIN, 15);
			
			JLabel label = new JLabel("员工姓名：");
			label.setFont(font);
			label.setBounds(50,25,110,20);
			
			username = new JTextField();
			username.setBounds(130, 25, 100, 20);
			username.setColumns(10);
			
			JLabel label1 = new JLabel("状态：");
			label1.setFont(font);
			label1.setBounds(250,25,70,20);
	
			state = new JComboBox<String>();
			state.setBounds(300, 25, 100, 20);
			state.addItem(null);
			state.addItem("待审核");
			state.addItem("通过");
			state.addItem("驳回");
			state.setFont(font);
			
			JLabel label2 = new JLabel("日期：");
			label2.setFont(font);
			label2.setBounds(450,25,70,20);
			
			daytime = new JTextField();
			daytime.setBounds(500, 25, 100, 20);
			daytime.setColumns(10);
			
			JButton tijiao = new JButton("查询");
			tijiao.setFont(font);
            tijiao.setBounds(775, 25, 70, 20); 
            
            JButton shou = new JButton("首页");
            shou.setFont(font);
            shou.setBounds(115, 400, 90, 20);
            
            JButton shang = new JButton("上一页");
            shang.setFont(font);
            shang.setBounds(295, 400, 90, 20);
            
            JButton xia = new JButton("下一页");
            xia.setFont(font);
            xia.setBounds(475, 400, 90, 20);
            
            JButton wei = new JButton("尾页");
            wei.setFont(font);
            wei.setBounds(655, 400, 90, 20);
            
          JScrollPane scrollPane = new JScrollPane();
			scrollPane.setBounds(8, 67, 919, 202);
			getContentPane().add(scrollPane);
            table = new JTable();
			table.setFont(new Font("微软雅黑", Font.PLAIN, 15));
			DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// 设置table内容居中
			tcr.setHorizontalAlignment(SwingConstants.CENTER);// 这句和上句作用一样
			table.setDefaultRenderer(Object.class, tcr);
			head=new String[] {
					"编号", "姓名", "旧部门", "新部门", "旧职务", "新职务", "调整原因", "申请时间" ,"审核人" ,"审核状态" 
			        };
			
			table.setModel(new DefaultTableModel(queryData(ll, pages, yeshu),head));
			scrollPane.setViewportView(table);
			
            contentPane.add(tijiao);  
			contentPane.add(label);
			contentPane.add(username);
			contentPane.add(label1);
			contentPane.add(state);
			contentPane.add(label2);
			contentPane.add(daytime);
			contentPane.add(scrollPane);
			contentPane.add(shang);
			contentPane.add(xia);
			contentPane.add(shou);
			contentPane.add(wei);

			tijiao.addActionListener(new ActionListener() {
    			@Override
    			public void actionPerformed(ActionEvent e) {
    				Adjustment a2 = new Adjustment();
    				String u_name = username.getText();
    				String states = (String) state.getSelectedItem();
    				String day = daytime.getText();
    				
    				if(day.equals("") || null == day  ) {
    					
    				}else {
    					a2.setAdj_time1(day+" 00:00:00");
    					a2.setAdj_time2(day+" 23:59:59");
    				}	    				
    					a2.setAdj_uname(u_name);
    					if(null == states || states.equals("")) {
    					}else {
    						if(states.equals("待审核")) {
    							a2.setAdj_audit(0);
    						}else if(states.equals("通过")){
    							a2.setAdj_audit(1);
    						}else {
    							a2.setAdj_audit(2);
    						}
    					}
    				
    				Page<Adjustment> page = PageHelper.startPage(1, 10);
    				List<Adjustment> ll = dts.adjustmentSelectByTiaojian(a2);
    				int pages = page.getPages();
    				dispose();
    				new HRJFrame().new SelectAll(ll,pages,1,2,a2).setVisible(true);	
    			}
    		});
			
			shou.addActionListener(new ActionListener() {

				@Override
    			public void actionPerformed(ActionEvent e) {
					if(type==1) {
						int xin = 1;
    					Page<Adjustment> page = PageHelper.startPage(xin, 10);
    					List<Adjustment> ll = dts.adjustmentSelectAll();
    					int pages = page.getPages();
    					dispose();
    					new HRJFrame().new SelectAll(ll,pages,xin,type,aa).setVisible(true);
					}else {
						Page<Adjustment> page = PageHelper.startPage(1, 10);
	    				List<Adjustment> ll = dts.adjustmentSelectByTiaojian(adj);
	    				int pages = page.getPages();
	    				dispose();
	    				new HRJFrame().new SelectAll(ll,pages,1,2,adj).setVisible(true);	
					}
    					
    				
    			}
    		});
			
			shang.addActionListener(new ActionListener() {

				@Override
    			public void actionPerformed(ActionEvent e) {
					
    				if(yeshu==1) {
    					showMessageDialog("当前为第一页");
    				}else {
    					int xin = yeshu-1;
    					if(type == 1) {
        					Page<Adjustment> page = PageHelper.startPage(xin, 10);
        					List<Adjustment> ll = dts.adjustmentSelectAll();
        					int pages = page.getPages();
        					dispose();
        					new HRJFrame().new SelectAll(ll,pages,xin,type,aa).setVisible(true);
    					}else {
    						Page<Adjustment> page = PageHelper.startPage(xin, 10);
    	    				List<Adjustment> ll = dts.adjustmentSelectByTiaojian(adj);
    	    				int pages = page.getPages();
    	    				dispose();
    	    				new HRJFrame().new SelectAll(ll,pages,1,2,adj).setVisible(true);
    					}
    					
    				}
    			}
    		});
			
			xia.addActionListener(new ActionListener() {

				@Override
    			public void actionPerformed(ActionEvent e) {
					
    				if(yeshu==pages){
    					System.out.println("yeshu = "+yeshu+"pages = "+pages);
    					showMessageDialog("当前条件没有更多记录");
    				}else {
    					int xin = yeshu+1;
    					if(type==1) {
    						Page<Adjustment> page = PageHelper.startPage(xin, 10);
        					List<Adjustment> ll = dts.adjustmentSelectAll();
        					int pages = page.getPages();
        					dispose();
        					new HRJFrame().new SelectAll(ll,pages,xin,type,aa).setVisible(true);
    					}else {
    						Page<Adjustment> page = PageHelper.startPage(xin, 10);
    	    				List<Adjustment> ll = dts.adjustmentSelectByTiaojian(adj);
    	    				int pages = page.getPages();
    	    				dispose();
    	    				new HRJFrame().new SelectAll(ll,pages,1,2,adj).setVisible(true);
    					}
    					
    				}
    			}
    		});
			
			wei.addActionListener(new ActionListener() {

				@Override
    			public void actionPerformed(ActionEvent e) {
					
    					int xin = pages;
    					if(type==1) {
        					Page<Adjustment> page = PageHelper.startPage(xin, 10);
        					List<Adjustment> ll = dts.adjustmentSelectAll();
        					int pages = page.getPages();
        					dispose();
        					new HRJFrame().new SelectAll(ll,pages,xin,type,aa).setVisible(true);
    					}else {
    						Page<Adjustment> page = PageHelper.startPage(xin, 10);
    	    				List<Adjustment> ll = dts.adjustmentSelectByTiaojian(adj);
    	    				int pages = page.getPages();
    	    				dispose();
    	    				new HRJFrame().new SelectAll(ll,pages,1,2,adj).setVisible(true);	
    					}
    				
    			}
    		});
						
		}
		
		 
		
		//生成表格数据
	    /**
	     * @return
	     */
	    public Object[][] queryData(List<Adjustment> ll, int pages, int yeshu){
	        data = new Object[10][head.length];
	        for(int i=0;i<10;i++){
	            for(int j=0;j<head.length;j++){
	            	if(i>ll.size()-1) {
	            		 data[i][0]=null;
	                     data[i][1]=null;
	                     data[i][2]=null;
	                     data[i][3]=null;
	                     data[i][4]=null;
	                     data[i][5]=null;
	                     data[i][6]=null;
	                     data[i][7]=null;
	                     data[i][8]=null;
	                     data[i][9]=null;
	            	}else {
	            		 data[i][0]=ll.get(i).getAdj_id();
	                     data[i][1]=ll.get(i).getAdj_uname();
	                     data[i][2]=ll.get(i).getAdj_odname();
	                     data[i][3]=ll.get(i).getAdj_ndname();
	                     data[i][4]=ll.get(i).getAdj_opname();
	                     data[i][5]=ll.get(i).getAdj_npname();
	                     data[i][6]=ll.get(i).getAdj_reason();
	                     data[i][7]=new DateFormatUtil().getDateString(ll.get(i).getAdj_time(),"YYYY-MM-dd HH:mm:ss");
	                     data[i][8]=ll.get(i).getAdj_auname();
	                     if(ll.get(i).getAdj_audit()==0) {
	                    	 data[i][9]="待审核";
	                     }else if(ll.get(i).getAdj_audit()==1) {
	                    	 data[i][9]="通过";
	                     }else if(ll.get(i).getAdj_audit()==2) {
	                    	 data[i][9]="驳回";
	                     }  
	                     
	                    
	            	}
	            }
	        }
	        return data;
	    }
	}
	
	class LzSelectAll extends BumenJFrame {

		public LzSelectAll(List<Resign> list, final int pages, final int yeshu,final int type,final Resign adj) {
			// TODO Auto-generated constructor stub
			super();
			//设置标题
			setTitle("离职申请记录");
			//设置大小
			setBounds(500,300,950,500);
			//主体
			contentPane = new JPanel();
			contentPane.setBorder(new EmptyBorder(500,300,950,500));
			setContentPane(contentPane);
			contentPane.setLayout(null);
			//创建1个字体实bai例
			Font font = new Font("宋体", Font.PLAIN, 15);
			
			JLabel label = new JLabel("员工姓名：");
			label.setFont(font);
			label.setBounds(50,25,110,20);
			
			username = new JTextField();
			username.setBounds(130, 25, 100, 20);
			username.setColumns(10);
			
			JLabel label1 = new JLabel("状态：");
			label1.setFont(font);
			label1.setBounds(250,25,70,20);
	
			state = new JComboBox<String>();
			state.setBounds(300, 25, 100, 20);
			state.addItem(null);
			state.addItem("待审核");
			state.addItem("通过");
			state.addItem("驳回");
			state.setFont(font);
			
			JLabel label2 = new JLabel("日期：");
			label2.setFont(font);
			label2.setBounds(450,25,70,20);
			
			daytime = new JTextField();
			daytime.setBounds(500, 25, 100, 20);
			daytime.setColumns(10);
			
			JButton tijiao = new JButton("查询");
			tijiao.setFont(font);
            tijiao.setBounds(775, 25, 70, 20); 
            
            JButton shou = new JButton("首页");
            shou.setFont(font);
            shou.setBounds(115, 400, 90, 20);
            
            JButton shang = new JButton("上一页");
            shang.setFont(font);
            shang.setBounds(295, 400, 90, 20);
            
            JButton xia = new JButton("下一页");
            xia.setFont(font);
            xia.setBounds(475, 400, 90, 20);
            
            JButton wei = new JButton("尾页");
            wei.setFont(font);
            wei.setBounds(655, 400, 90, 20);
            
          JScrollPane scrollPane = new JScrollPane();
			scrollPane.setBounds(8, 67, 919, 202);
			getContentPane().add(scrollPane);
            table = new JTable();
			table.setFont(new Font("微软雅黑", Font.PLAIN, 15));
			DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// 设置table内容居中
			tcr.setHorizontalAlignment(SwingConstants.CENTER);// 这句和上句作用一样
			table.setDefaultRenderer(Object.class, tcr);
			head=new String[] {
					"编号", "姓名", "离职时间", "离职原因", "审批人姓名", "状态" 
			        };
			
			table.setModel(new DefaultTableModel(queryData1(list, pages, yeshu),head));
			scrollPane.setViewportView(table);
			
            contentPane.add(tijiao);  
			contentPane.add(label);
			contentPane.add(username);
			contentPane.add(label1);
			contentPane.add(state);
			contentPane.add(label2);
			contentPane.add(daytime);
			contentPane.add(scrollPane);
			contentPane.add(shang);
			contentPane.add(xia);
			contentPane.add(shou);
			contentPane.add(wei);

			tijiao.addActionListener(new ActionListener() {
    			@Override
    			public void actionPerformed(ActionEvent e) {
    				Resign a2 = new Resign();
    				String u_name = username.getText();
    				String states = (String) state.getSelectedItem();
    				String day = daytime.getText();
    				
    				if(day.equals("") || null == day  ) {
    					
    				}else {
    					a2.setRg_time1(day+" 00:00:00");
    					a2.setRg_time2(day+" 23:59:59");
    				}	    				
    					a2.setRg_name(u_name);
    					if(null == states || states.equals("")) {
    					}else {
    						if(states.equals("待审核")) {
    							a2.setRg_audit(0);
    						}else if(states.equals("通过")){
    							a2.setRg_audit(1);
    						}else {
    							a2.setRg_audit(2);
    						}
    					}
    				
    				Page<Resign> page = PageHelper.startPage(1, 10);
    				List<Resign> ll = dts.resignSelectByTiaojian(a2);
    				int pages = page.getPages();
    				dispose();
    				new HRJFrame().new LzSelectAll(ll,pages,1,2,a2).setVisible(true);	
    			}
    		});
			
			shou.addActionListener(new ActionListener() {

				@Override
    			public void actionPerformed(ActionEvent e) {
					if(type==1) {
						int xin = 1;
    					Page<Resign> page = PageHelper.startPage(xin, 10);
    					List<Resign> ll = dts.ResignSelectAll();
    					int pages = page.getPages();
    					dispose();
    					new HRJFrame().new LzSelectAll(ll,pages,xin,type,rr).setVisible(true);
					}else {
						Page<Resign> page = PageHelper.startPage(1, 10);
	    				List<Resign> ll = dts.resignSelectByTiaojian(adj);
	    				int pages = page.getPages();
	    				dispose();
	    				new HRJFrame().new LzSelectAll(ll,pages,1,2,adj).setVisible(true);	
					}
    					
    				
    			}
    		});
			
			shang.addActionListener(new ActionListener() {

				@Override
    			public void actionPerformed(ActionEvent e) {
					
    				if(yeshu==1) {
    					showMessageDialog("当前为第一页");
    				}else {
    					int xin = yeshu-1;
    					if(type == 1) {
        					Page<Resign> page = PageHelper.startPage(xin, 10);
        					List<Resign> ll = dts.ResignSelectAll();
        					int pages = page.getPages();
        					dispose();
        					new HRJFrame().new LzSelectAll(ll,pages,xin,type,rr).setVisible(true);
    					}else {
    						Page<Resign> page = PageHelper.startPage(xin, 10);
    	    				List<Resign> ll = dts.resignSelectByTiaojian(adj);
    	    				int pages = page.getPages();
    	    				dispose();
    	    				new HRJFrame().new LzSelectAll(ll,pages,1,2,adj).setVisible(true);
    					}
    					
    				}
    			}
    		});
			
			xia.addActionListener(new ActionListener() {

				@Override
    			public void actionPerformed(ActionEvent e) {
					
    				if(yeshu==pages){
    					System.out.println("yeshu = "+yeshu+"pages = "+pages);
    					showMessageDialog("当前条件没有更多记录");
    				}else {
    					int xin = yeshu+1;
    					if(type==1) {
    						Page<Resign> page = PageHelper.startPage(xin, 10);
        					List<Resign> ll = dts.ResignSelectAll();
        					int pages = page.getPages();
        					dispose();
        					new HRJFrame().new LzSelectAll(ll,pages,xin,type,rr).setVisible(true);
    					}else {
    						Page<Resign> page = PageHelper.startPage(xin, 10);
    	    				List<Resign> ll = dts.resignSelectByTiaojian(adj);
    	    				int pages = page.getPages();
    	    				dispose();
    	    				new HRJFrame().new LzSelectAll(ll,pages,1,2,adj).setVisible(true);
    					}
    					
    				}
    			}
    		});
			
			wei.addActionListener(new ActionListener() {

				@Override
    			public void actionPerformed(ActionEvent e) {
					
    					int xin = pages;
    					if(type==1) {
        					Page<Resign> page = PageHelper.startPage(xin, 10);
        					List<Resign> ll = dts.ResignSelectAll();
        					int pages = page.getPages();
        					dispose();
        					new HRJFrame().new LzSelectAll(ll,pages,xin,type,rr).setVisible(true);
    					}else {
    						Page<Resign> page = PageHelper.startPage(xin, 10);
    	    				List<Resign> ll = dts.resignSelectByTiaojian(adj);
    	    				int pages = page.getPages();
    	    				dispose();
    	    				new HRJFrame().new LzSelectAll(ll,pages,1,2,adj).setVisible(true);	
    					}
    				
    			}
    		});
						
		}
		
		 
		
		//生成表格数据
	    /**
	     * @return
	     */
	    public Object[][] queryData1(List<Resign> list, int pages, int yeshu){
	        data = new Object[10][head.length];
	        for(int i=0;i<10;i++){
	            for(int j=0;j<head.length;j++){
	            	if(i>list.size()-1) {
	            		 data[i][0]=null;
	                     data[i][1]=null;
	                     data[i][2]=null;
	                     data[i][3]=null;
	                     data[i][4]=null;
	                     data[i][5]=null;	                
	            	}else {
	            		 data[i][0]=list.get(i).getRg_id();
	                     data[i][1]=list.get(i).getRg_name();
	                     data[i][2]=new DateFormatUtil().getDateString(list.get(i).getRg_time(),"YYYY-MM-dd HH:mm:ss");
	                     data[i][3]=list.get(i).getRg_reason();
	                     data[i][4]=list.get(i).getRg_auname();
	                     if(list.get(i).getRg_audit()==0) {
	                    	 data[i][5]="待审核";
	                     }else if(list.get(i).getRg_audit()==1) {
	                    	 data[i][5]="通过";
	                     }else if(list.get(i).getRg_audit()==2) {
	                    	 data[i][5]="驳回";
	                     }  
	                     
	                    
	            	}
	            }
	        }
	        return data;
	    }
	}
	
	
	
	class JjSelectAll extends BumenJFrame {

		public JjSelectAll(List<Bonus> list, final int pages, final int yeshu,final int type,final Bonus adj) {
			// TODO Auto-generated constructor stub
			super();
			//设置标题
			setTitle("奖金申请记录");
			//设置大小
			setBounds(500,300,950,500);
			//主体
			contentPane = new JPanel();
			contentPane.setBorder(new EmptyBorder(500,300,950,500));
			setContentPane(contentPane);
			contentPane.setLayout(null);
			//创建1个字体实bai例
			Font font = new Font("宋体", Font.PLAIN, 15);
			
			JLabel label = new JLabel("员工姓名：");
			label.setFont(font);
			label.setBounds(50,25,110,20);
			
			username = new JTextField();
			username.setBounds(130, 25, 100, 20);
			username.setColumns(10);
			
			JLabel label1 = new JLabel("状态：");
			label1.setFont(font);
			label1.setBounds(250,25,70,20);
	
			state = new JComboBox<String>();
			state.setBounds(300, 25, 100, 20);
			state.addItem(null);
			state.addItem("待审核");
			state.addItem("通过");
			state.addItem("驳回");
			state.setFont(font);
			
			JLabel label2 = new JLabel("日期：");
			label2.setFont(font);
			label2.setBounds(450,25,70,20);
			
			daytime = new JTextField();
			daytime.setBounds(500, 25, 100, 20);
			daytime.setColumns(10);
			
			JButton tijiao = new JButton("查询");
			tijiao.setFont(font);
            tijiao.setBounds(775, 25, 70, 20); 
            
            JButton shou = new JButton("首页");
            shou.setFont(font);
            shou.setBounds(115, 400, 90, 20);
            
            JButton shang = new JButton("上一页");
            shang.setFont(font);
            shang.setBounds(295, 400, 90, 20);
            
            JButton xia = new JButton("下一页");
            xia.setFont(font);
            xia.setBounds(475, 400, 90, 20);
            
            JButton wei = new JButton("尾页");
            wei.setFont(font);
            wei.setBounds(655, 400, 90, 20);
            
          JScrollPane scrollPane = new JScrollPane();
			scrollPane.setBounds(8, 67, 919, 202);
			getContentPane().add(scrollPane);
            table = new JTable();
			table.setFont(new Font("微软雅黑", Font.PLAIN, 15));
			DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// 设置table内容居中
			tcr.setHorizontalAlignment(SwingConstants.CENTER);// 这句和上句作用一样
			table.setDefaultRenderer(Object.class, tcr);
			head=new String[] {
					"编号", "姓名", "金额", "申请时间", "申请原因", "审批人姓名", "状态" 
			        };
			
			table.setModel(new DefaultTableModel(queryData2(list, pages, yeshu),head));
			scrollPane.setViewportView(table);
			
            contentPane.add(tijiao);  
			contentPane.add(label);
			contentPane.add(username);
			contentPane.add(label1);
			contentPane.add(state);
			contentPane.add(label2);
			contentPane.add(daytime);
			contentPane.add(scrollPane);
			contentPane.add(shang);
			contentPane.add(xia);
			contentPane.add(shou);
			contentPane.add(wei);

			tijiao.addActionListener(new ActionListener() {
    			@Override
    			public void actionPerformed(ActionEvent e) {
    				Bonus a2 = new Bonus();
    				String u_name = username.getText();
    				String states = (String) state.getSelectedItem();
    				String day = daytime.getText();
    				
    				if(day.equals("") || null == day  ) {
    					
    				}else {
    					a2.setBo_time1(day+" 00:00:00");
    					a2.setBo_time2(day+" 23:59:59");
    				}	    				
    					a2.setBo_uname(u_name);
    					if(null == states || states.equals("")) {
    					}else {
    						if(states.equals("待审核")) {
    							a2.setBo_audit(0);
    						}else if(states.equals("通过")){
    							a2.setBo_audit(1);
    						}else {
    							a2.setBo_audit(2);
    						}
    					}
    				
    				Page<Bonus> page = PageHelper.startPage(1, 10);
    				List<Bonus> ll = dts.bonusSelectByTiaojian(a2);
    				int pages = page.getPages();
    				dispose();
    				new HRJFrame().new JjSelectAll(ll,pages,1,2,a2).setVisible(true);	
    			}
    		});
			
			shou.addActionListener(new ActionListener() {

				@Override
    			public void actionPerformed(ActionEvent e) {
					if(type==1) {
						int xin = 1;
    					Page<Bonus> page = PageHelper.startPage(xin, 10);
    					List<Bonus> ll = dts.bonusSelectAll();
    					int pages = page.getPages();
    					dispose();
    					new HRJFrame().new JjSelectAll(ll,pages,xin,type,bb).setVisible(true);
					}else {
						Page<Bonus> page = PageHelper.startPage(1, 10);
	    				List<Bonus> ll = dts.bonusSelectByTiaojian(adj);
	    				int pages = page.getPages();
	    				dispose();
	    				new HRJFrame().new JjSelectAll(ll,pages,1,2,adj).setVisible(true);	
					}
    					
    				
    			}
    		});
			
			shang.addActionListener(new ActionListener() {

				@Override
    			public void actionPerformed(ActionEvent e) {
					
    				if(yeshu==1) {
    					showMessageDialog("当前为第一页");
    				}else {
    					int xin = yeshu-1;
    					if(type == 1) {
        					Page<Bonus> page = PageHelper.startPage(xin, 10);
        					List<Bonus> ll = dts.bonusSelectAll();
        					int pages = page.getPages();
        					dispose();
        					new HRJFrame().new JjSelectAll(ll,pages,xin,type,bb).setVisible(true);
    					}else {
    						Page<Bonus> page = PageHelper.startPage(xin, 10);
    	    				List<Bonus> ll = dts.bonusSelectByTiaojian(adj);
    	    				int pages = page.getPages();
    	    				dispose();
    	    				new HRJFrame().new JjSelectAll(ll,pages,1,2,adj).setVisible(true);
    					}
    					
    				}
    			}
    		});
			
			xia.addActionListener(new ActionListener() {

				@Override
    			public void actionPerformed(ActionEvent e) {
					
    				if(yeshu==pages){
    					showMessageDialog("当前条件没有更多记录");
    				}else {
    					int xin = yeshu+1;
    					if(type==1) {
    						Page<Bonus> page = PageHelper.startPage(xin, 10);
        					List<Bonus> ll = dts.bonusSelectAll();
        					int pages = page.getPages();
        					dispose();
        					new HRJFrame().new JjSelectAll(ll,pages,xin,type,bb).setVisible(true);
    					}else {
    						Page<Bonus> page = PageHelper.startPage(xin, 10);
    	    				List<Bonus> ll = dts.bonusSelectByTiaojian(adj);
    	    				int pages = page.getPages();
    	    				dispose();
    	    				new HRJFrame().new JjSelectAll(ll,pages,1,2,adj).setVisible(true);
    					}
    					
    				}
    			}
    		});
			
			wei.addActionListener(new ActionListener() {

				@Override
    			public void actionPerformed(ActionEvent e) {
					
    					int xin = pages;
    					if(type==1) {
        					Page<Bonus> page = PageHelper.startPage(xin, 10);
        					List<Bonus> ll = dts.bonusSelectAll();
        					int pages = page.getPages();
        					dispose();
        					new HRJFrame().new JjSelectAll(ll,pages,xin,type,bb).setVisible(true);
    					}else {
    						Page<Bonus> page = PageHelper.startPage(xin, 10);
    	    				List<Bonus> ll = dts.bonusSelectByTiaojian(adj);
    	    				int pages = page.getPages();
    	    				dispose();
    	    				new HRJFrame().new JjSelectAll(ll,pages,1,2,adj).setVisible(true);	
    					}
    				
    			}
    		});
						
		}
		
		 
		
		//生成表格数据
	    /**
	     * @return
	     */
	    public Object[][] queryData2(List<Bonus> list, int pages, int yeshu){
	        data = new Object[10][head.length];
	        for(int i=0;i<10;i++){
	            for(int j=0;j<head.length;j++){
	            	if(i>list.size()-1) {
	            		 data[i][0]=null;
	                     data[i][1]=null;
	                     data[i][2]=null;
	                     data[i][3]=null;
	                     data[i][4]=null;
	                     data[i][5]=null;	                
	            	}else {
	            		 data[i][0]=list.get(i).getBo_id();
	                     data[i][1]=list.get(i).getBo_uname();
	                     data[i][2]=list.get(i).getBo_money();
	                     data[i][3]=new DateFormatUtil().getDateString(list.get(i).getBo_time(),"YYYY-MM-dd HH:mm:ss");
	                     data[i][4]=list.get(i).getBo_reason();
	                     data[i][5]=list.get(i).getBo_auname();
	                     if(list.get(i).getBo_audit()==0) {
	                    	 data[i][6]="待审核";
	                     }else if(list.get(i).getBo_audit()==1) {
	                    	 data[i][6]="通过";
	                     }else if(list.get(i).getBo_audit()==2) {
	                    	 data[i][6]="驳回";
	                     }  
	                     
	                    
	            	}
	            }
	        }
	        return data;
	    }
	}
	
}
